package tk.winshu.starter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author Kevin
 * @since 2019/03/30.
 */
@EnableConfigurationProperties(WinshuProperties.class)
@ConditionalOnMissingBean(WinshuConfiguration.class)
public class WinshuAutoConfiguration {

    @Autowired
    private WinshuProperties winshuProperties;

    @Bean
    public WinshuConfiguration winshuConfiguration() {
        WinshuConfiguration configuration = new WinshuConfiguration();
        configuration.setName(winshuProperties.getName());
        configuration.setDescription(winshuProperties.getDescription());
        configuration.setHost(winshuProperties.getHost());
        return configuration;
    }
}
